
const v1 = new Vue({
    el:"#login-main",
    data:{
        result:"",
        admin:{
            id:0,
            username:"",
            password:""
        }
    },
    methods:{
        loginClick:function (){
            var username = v1.admin.username;
            var password = v1.admin.password;
            if (username != null && username != ""){
                //alert("usernam: "+username);
                if (password != null && password != ""){
                    //alert("password: " + password);
                    let index = layer.msg("登录中...",{icon:16});
                    this.$http.post("v1/login",v1.admin,{"emulateJSON":true}).then(function (data){
                        layer.close(index);
                        var status = data.data.status;
                        var resultMsg = data.data.msg;
                        if (status == -1){
                            //登录失败
                            layer.msg(resultMsg);
                        }else {
                            //登录成功
                            layer.msg(resultMsg);
                            var userid = data.data.data.id;
                            //alert("userid: " + userid);
                            self.location='u.html?'+'userid='+userid;
                        }
                    },function (data){
                    });
                }else {
                    layer.msg("请输入密码");
                }
            }else {
                layer.msg("请输入账号");
            }

        }
    }
});